function Throttle(callback, interval) {
	if (this instanceof Throttle) {
		this.callback = callback;
		this.interval = interval || 500;
		this.firstTime = true;
		this.timer = null;
	} else {
		return new Throttle(callback, interval);
	}
}

Throttle.prototype.throttle = function (...args) {
	let _this = this;
	if (this.firstTime) {
		this.callback.call(_this, ...args);
		this.firstTime = false;
	}
	if (this.timer) {
		return false;
	}
	this.timer = setTimeout(() => {
		_this.off();
		_this.callback.call(_this, ...args);
	}, _this.interval);
};

Throttle.prototype.off = function () {
	clearTimeout(this.timer);
	this.timer = null;
};

export default Throttle;
